package com.xiaoye.qbproject.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaoye.qbproject.config.XiaoYeConfig;
import com.xiaoye.qbproject.domain.QbWarfareMedia;
import com.xiaoye.qbproject.mapper.QbWarfareMediaMapper;
import com.xiaoye.qbproject.service.QbWarfareMediaService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class QbWarfareMediaServiceImpl extends ServiceImpl<QbWarfareMediaMapper, QbWarfareMedia> implements QbWarfareMediaService {

    @Override
    public List<QbWarfareMedia> listByWarfareId(String warfareId) {
        List<QbWarfareMedia> mediaList = this.list(new LambdaQueryWrapper<QbWarfareMedia>()
                .eq(QbWarfareMedia::getWarfareId, warfareId));

        // 处理全路径
        mediaList.forEach(media -> {
            String fullPath = XiaoYeConfig.getZlprofile() + "/" + media.getWarfareName() + "/" + media.getPath();
            media.setFullPath(fullPath);
        });

        return mediaList;
    }
}
